package com.learn.edupay.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * RabbitMQ的配置
 */
@Slf4j
@Configuration
public class RabbitMQConfig {

    public static final String KEY = "queue.pay.callback";
    public static final String EXCHANGE = "pay.callback.exchange";

    @Bean
    public Queue queue() {
        return new Queue(KEY);
    }

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange(EXCHANGE);
    }

    @Bean
    public Binding bind() {
        return BindingBuilder.bind(queue()).to(topicExchange()).with(KEY);
    }

}
